package com.cheyun.netsalev3.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cheyun.netsalev3.R;
import com.cheyun.netsalev3.bean.DialogParam;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;

import java.util.List;

public class CustomerEditTagAdapter extends TagAdapter<DialogParam> {

    private Context context;
    private boolean enableEdit;
    public CustomerEditTagAdapter(Context context, List<DialogParam> datas,boolean enableEdit) {
        super(datas);
        this.context=context;
        this.enableEdit = enableEdit;
    }

    @Override
    public View getView(FlowLayout parent, int position, DialogParam data) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.customer_tag_edit_item, parent, false);
        TextView tv = view.findViewById(R.id.tv_oper_name);
        RelativeLayout rl = view.findViewById(R.id.rl_customer_tag);
        ImageView iv = view.findViewById(R.id.iv_del);
        tv.setText(data.getName());
        if(!enableEdit) iv.setVisibility(View.GONE);
        if(data.getIcon().equals("1")){
            tv.setTextColor(context.getResources().getColor(R.color.white));
            rl.setBackground(context.getResources().getDrawable(R.drawable.rectangle_15dp_lan));
        }
        return view;
    }
}
